#!/bin/bash
   #chkconfig: 345 99 50
   #description: Start selenium
   if [ -z "$1" ]; then
   echo "`basename $0` {start|stop}"
       exit
   fi

   case "$1" in
   start)
       #export DISPLAY=:99
       DISPLAY=:99 xvfb-run java -jar /tmp/selenium/selenium-server-standalone-2.53.0.jar  > /tmp/selenium.log 2>&1 & >/dev/null 2>&1 &
       echo $! > /var/run/selenium.pid
   ;;

   stop)
       if [ -f /var/run/selenium.pid ]; then
	pid=`cat /var/run/selenium.pid`
        kill -9 ${pid} > /dev/null
       fi
   ;;
   esac
